#!/bin/sh
## 创建及加载表数据到hive中
## 创建音乐日志表与加载日志文件数据
echo `hive -e "drop table d_music_log;"`
echo `hive -e "create table d_music_log(time string,opt_type string, user_id string,music_id string)  COMMENT 'MUSIC LOG TABLE' row format delimited fields terminated by '\t';"`
echo `hive -e "LOAD DATA LOCAL INPATH '${HOME}/vmusic_data/d_music_log.txt' OVERWRITE INTO TABLE d_music_log;"`
## 创建地区表与地区文件数据
echo `hive -e "drop table s_region;"`
echo `hive -e "create table s_region(id string,decr_name string)  COMMENT 'REGION INFO TABLE' row format delimited fields terminated by '\t';"`
echo `hive -e "LOAD DATA LOCAL INPATH '${HOME}/vmusic_data/s_region.txt' OVERWRITE INTO TABLE s_region;"`
## 创建语言表与加载语言数据
echo `hive -e "drop table s_language;"`
echo `hive -e "create table s_language(id string,decr_name string)  COMMENT 'MUSIC LANGUAGE INFO TABLE' row format delimited fields terminated by '\t';"`
echo `hive -e "LOAD DATA LOCAL INPATH '${HOME}/vmusic_data/s_language.txt' OVERWRITE INTO TABLE s_language;"`
## 创建音乐类型表与加载音乐类型数据
echo `hive -e "drop table s_music_type;"`
echo `hive -e "create table s_music_type(id string,decr_name string)  COMMENT 'MUSIC TYPE  TABLE' row format delimited fields terminated by '\t' ;"`
echo `hive -e "LOAD DATA LOCAL INPATH '${HOME}/vmusic_data/s_music_type.txt' OVERWRITE INTO TABLE s_music_type ;"`
## 创建音乐表与加载音乐数据
echo `hive -e "drop table d_music;"`
echo `hive -e "create table d_music(id string,name string,type string,singer_name string ,language string,show_time string) row format delimited fields terminated by '\t' ;"`
echo `hive -e "load data local INPATH '${HOME}/vmusic_data/d_music.txt' overwrite into table d_music ;"`
## 创建用户表与加载用户数据
echo `hive -e "drop table d_user;"`
echo `hive -e "create table d_user(id string,name string,sex string,birthday string,city string) row format delimited fields terminated by '\t';"`
echo `hive -e "load data local INPATH '${HOME}/vmusic_data/d_user.txt' overwrite into table d_user;"`
## 创建演唱者表与加载演唱者数据
echo `hive -e "drop table d_singer;"`
echo `hive -e "create table d_singer(id string,name string,sex string,region string) row format delimited fields terminated by '\t';"`
echo `hive -e "load data local INPATH '${HOME}/vmusic_data/d_singer.txt' overwrite into table d_singer;"`